﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ANZ_AIM_GUI.Utils;
using ANZ_AIM_DAL;
using ANZ_AIM_BLL;
using ANZ_AIM_BLL.Model;
using log4net;

namespace ANZ_AIM_GUI
{
    public partial class frmDataSQMRawData : Form
    {
        //log4net
        private static readonly ILog logger = LogManager.GetLogger(typeof(frmDataSQMRawData));

        public Dictionary<string, string> SaleSQMRawData_FieldLabelDict { get; set; }
        public frmDataSQMRawData()
        {
            InitializeComponent();
        }

        public frmDataSQMRawData(string SaleCode,string batchFileSaleInfoID)
            : this()
        {
            try
            {
                BuildLabel();

                SaleSQMRawDataBLL saleSQMRawDataBll = new SaleSQMRawDataBLL();
                DataTable dtResult = saleSQMRawDataBll.GetBySaleCodeAndMonth(SaleCode, batchFileSaleInfoID);

                dgvData.DataSource = null;
                dgvData.Columns.Clear();
                dgvData.DataSource = dtResult;
                dgvData.AutoResizeColumns();

                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(SaleSQMRawDataBLL));
                foreach (PropertyDescriptor prop in properties)
                {
                    dgvData.Columns[prop.Name].HeaderText = SaleSQMRawData_FieldLabelDict[prop.Name];
                }
            }
            catch (Exception ex) { throw ex; }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void BuildLabel()
        {
            try
            {
                SaleSQMRawData_FieldLabelDict = new Dictionary<string, string>();
                SaleSQMRawData_FieldLabelDict.Add("ID", "ID");
                SaleSQMRawData_FieldLabelDict.Add("ProductType", "Product Type");
                SaleSQMRawData_FieldLabelDict.Add("ApprovedLimit", "Approved Limit");
                SaleSQMRawData_FieldLabelDict.Add("Type", "Type");
                SaleSQMRawData_FieldLabelDict.Add("Agent", "Agent");
                SaleSQMRawData_FieldLabelDict.Add("SaleName", "Sale Name");
                SaleSQMRawData_FieldLabelDict.Add("Team", "Team");
                SaleSQMRawData_FieldLabelDict.Add("Role", "Role");
                SaleSQMRawData_FieldLabelDict.Add("Incidents", "Incidents");
                SaleSQMRawData_FieldLabelDict.Add("IncidentCode", "Incident Code");
                SaleSQMRawData_FieldLabelDict.Add("RiskPoint", "Risk Point");
                SaleSQMRawData_FieldLabelDict.Add("Channel", "Channel");
                SaleSQMRawData_FieldLabelDict.Add("SourceCode", "Source Code");
                SaleSQMRawData_FieldLabelDict.Add("Fullname", "Full Name");
                SaleSQMRawData_FieldLabelDict.Add("SubmitDate", "Submit Date");
                SaleSQMRawData_FieldLabelDict.Add("Product", "Product");
                SaleSQMRawData_FieldLabelDict.Add("OpenDate", "Open Date");
                SaleSQMRawData_FieldLabelDict.Add("Month", "Month");
                SaleSQMRawData_FieldLabelDict.Add("BatchFileSaleInfoID", "Batch File Sale Info ID");
            }
            catch (Exception ex) { throw ex; }
        }
    }
}
